package com.tensquare.notice.client;

import entity.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Map;

@FeignClient("tensquare-article")
@RequestMapping("/article")   //feign接口的类上可以用@RequestMapping代表类路径
public interface ArticleClient {

    //根据文章id查询文章数据
    // GET /article/{articleId} 根据ID查询文章
    @GetMapping(value = "/{articleId}")   //方法上加RESTful风格的@GetMapping注解更加优雅
    public Result findById(@PathVariable("articleId") String articleId);

    /*//feign接口调用后,得到的数据时json形式的,没有类型(T类型),可以用适合的对象进行接收,
    //比如收到的是Result,可以被我们转成Map
    @RequestMapping(value = "/{articleId}", method = RequestMethod.GET)
    public Map<String,Object> findById(@PathVariable("articleId") String articleId);*/
}
